+2007-03-21 Rodney Dawes <dobey@novell.com>
+
+ * gtk/gtk.symbols:
+ * gtk/gtkicontheme.[ch]:
+ * docs/reference/gtk/gtk-sections.txt:
+ * tests/testicontheme.c:
+ Add a new API call gtk_icon_theme_list_contexts so that one can
+ choose icons from a theme by context (#420719)
+
2007-03-21 Ross Burton <ross@burtonini.com>
* gtk/gtktexttag.c:
static void theme_list_icons (IconTheme *theme,
GHashTable *icons,
GQuark context);
+static void theme_list_contexts (IconTheme *theme,
+ GHashTable *contexts);
static void theme_subdir_load (GtkIconTheme *icon_theme,
IconTheme *theme,
GKeyFile *theme_file,
return list;
}
+/**
+ * gtk_icon_theme_list_contexts:
+ * @icon_theme: a #GtkIconTheme
+ *
+ * Gets the list of contexts available within the current
+ * hierarchy of icon themes
+ *
+ * Return value: a #GList list holding the names of all the
+ * contexts in the theme. You must first free each element
+ * in the list with g_free(), then free the list itself
+ * with g_list_free().
+ *
+ * Since: 2.12
+ **/
+GList *
+gtk_icon_theme_list_contexts (GtkIconTheme *icon_theme)
+{
+ GtkIconThemePrivate *priv;
+ GHashTable *contexts;
+ GList *list, *l;
+
+ priv = icon_theme->priv;
+
+ ensure_valid_themes (icon_theme);
+
+ contexts = g_hash_table_new (g_str_hash, g_str_equal);
+
+ l = priv->themes;
+ while (l != NULL)
+ {
+ theme_list_contexts (l->data, contexts);
+ l = l->next;
+ }
+
+ list = NULL;
+
+ g_hash_table_foreach (contexts,
+ add_key_to_list,
+ &list);
+
+ g_hash_table_destroy (contexts);
+
+ return list;
+}
+
/**
* gtk_icon_theme_get_example_icon_name:
* @icon_theme: a #GtkIconTheme
}
}
+static void
+theme_list_contexts (IconTheme *theme,
+ GHashTable *contexts)
+{
+ GList *l = theme->dirs;
+ IconThemeDir *dir;
+ const char *context;
+
+ while (l != NULL)
+ {
+ dir = l->data;
+
+ context = g_quark_to_string (dir->context);
+ g_hash_table_replace (contexts, context, NULL);
+
+ l = l->next;
+ }
+}
+
static void
load_icon_data (IconThemeDir *dir, const char *path, const char *name)
{
"usage: test-icon-theme list <theme name> [context]\n"
" or\n"
"usage: test-icon-theme display <theme name> <icon name> [size]\n"
+ " or\n"
+ "usage: test-icon-theme contexts <theme name>\n"
);
}
list = gtk_icon_theme_list_icons (icon_theme,
context);
+ while (list)
+ {
+ g_print ("%s\n", (char *)list->data);
+ list = list->next;
+ }
+ }
+ else if (strcmp (argv[1], "contexts") == 0)
+ {
+ list = gtk_icon_theme_list_contexts (icon_theme);
+
while (list)
{
g_print ("%s\n", (char *)list->data);